package cn.com.smartdevices.bracelet.chart;

import android.content.Context;
import android.util.AttributeSet;

import com.goodving.guli.bt.profile.scale.GuliLog;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import cn.com.smartdevices.bracelet.chart.base.BaseChartView;
import cn.com.smartdevices.bracelet.chart.base.C0759p;
import cn.com.smartdevices.bracelet.chart.base.Renderer;

public class DynamicShareChartView extends BaseChartView<DynamicShareChart> {
    private static final String f3881a = "Chart.DynamicShareChartView";
    private Renderer f3882b;

    public DynamicShareChartView(Context context) {
        this(context, null);
    }

    public DynamicShareChartView(Context context, AttributeSet attributeSet) {
        this(context, attributeSet, 0);
    }

    public DynamicShareChartView(Context context, AttributeSet attributeSet, int i) {
        super(context, attributeSet, i);
        this.f3847e = new DynamicShareChart(context);
        this.f3882b = new C0759p(1090519039);
    }

    private void m8450a(List<DynamicDetailChartView.DynamicDetailChartStepData> list) {
        List arrayList = new ArrayList();
        for (DynamicDetailChartView.DynamicDetailChartStepData c0772n : list) {
            C0805v c0805v = new C0805v(getContext());
            c0805v.f3883b = c0772n.f4007b;
            c0805v.f3884c = c0772n.f4006a;
            c0805v.setRenderer(this.f3882b);
            arrayList.add(c0805v);
        }
        ((DynamicShareChart) this.f3847e).fillItems(arrayList);
        ((DynamicShareChart) this.f3847e).notifyChanged();
    }

    public void bindStepData (HashMap<Integer, Integer> hashMap) { // m8451a
        List arrayList = new ArrayList();
        int a = ((DynamicShareChart) this.f3847e).getTotalHours();
        int i = 0;
        for (Integer num : hashMap.keySet()) {
            i = num.intValue() > i ? num.intValue() : i;
        }
        GuliLog.tracePrintInfo(f3881a, "Max Index : " + i);
        if (i > a) {
            int i2 = i - a;
            i = i2 % 2 != 0 ? i2 + 2 : i2 + 1;
        } else {
            i = 1;
        }
        GuliLog.tracePrintInfo(f3881a, "Index Offset: " + i);
        ((DynamicShareChart) this.f3847e).setOffsetHour(i);
        for (int i3 = i; i3 < i + a; i3++) {
            DynamicDetailChartView.DynamicDetailChartStepData c0772n = new DynamicDetailChartView(getContext()).new DynamicDetailChartStepData();
            c0772n.f4006a = i3;
            if (hashMap.get(Integer.valueOf(i3)) != null) {
                c0772n.f4007b = ((Integer) hashMap.get(Integer.valueOf(i3))).intValue();
            }
            arrayList.add(c0772n);
        }
        m8450a(arrayList);
    }
}
